using System;
using System.Collections.Generic;
using System.Text;

namespace UKVSTS
{
    /// <summary>
    /// Simple class to add a name to any type.
    /// This name is then returned by ToString.
    /// This allows any type of object to be added to a combo box.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class NamedWrapper <T> where T : class
    {
        // The object being wrapped.
        //
        private T m_WrappedItem;

        // The name of the object that should show up in the combo box
        private String m_Name;

        /// <summary>
        /// Create an instance of the simple wrapper.
        /// </summary>
        /// <param name="item">The object to be wrapped</param>
        /// <param name="name">The name of the object instance</param>
        public NamedWrapper (T item, String name)
        {
            if (item == null)
            {
                throw new ArgumentNullException ("item");
            }
            if (String.IsNullOrEmpty (name))
            {
                throw new ArgumentNullException ("name");
            }

            m_WrappedItem = item;
            m_Name = name;
        }

        /// <summary>
        /// Returns the name of the object instance.
        /// </summary>
        public override string ToString ()
        {
            return m_Name;
        }

        /// <summary>
        /// The object that has been names.
        /// </summary>
        public T Item
        {
            get
            {
                return m_WrappedItem;
            }
        }

        /// <summary>
        /// Returns the name of the object instance.
        /// </summary>
        public String Name
        {
            get
            {
                return m_Name;
            }
        }

    }
}
